/***************************************************************
*  Copyright (c) 2007 by GroupMe! Team (www.groupme.net)
*  All rights reserved
*
*  This file is part of the GroupMe! Project. You can utilize
*  software of the GroupMe! project under the terms of the 
*  GNU Lesser General Public License as published by the
*  Free Software Foundation in version 2.1.
* 
*  The GNU Lesser General Public License can be found at:
*  http://www.gnu.org/licenses/lgpl.html
*
*  This copyright notice MUST APPEAR in all copies of the file!
***************************************************************/
package net.groupme.export;

import java.io.StringWriter;

import net.groupme.export.constants.General;
import net.groupme.export.rdf.GroupExport;
import net.groupme.export.rdf.ResourceExport;

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.vocabulary.DC;

/**
 * This class provides...
 *
 * @author Daniel Plappert
 * @version 0.1
 */
public class RdfExport extends AbstractExporter {
    

    public RdfExport() {};
    
    
    /**
     *
     *
     * @return String RDF-Data
     */
    public String doExport() {
        
        Model model = ModelFactory.createDefaultModel();
        model.setNsPrefix("dc", DC.NS);
        model.setNsPrefix("groupme", General.baseNamespace);
        model.setNsPrefix("foaf", General.foafNamespace);
        
        if ( groupData != null ) {
            GroupExport exportGroup = new GroupExport(ds);
            exportGroup.setData(groupData);
            exportGroup.exportData(model, true);
        } 
        
        if ( resourceData != null ) {
            ResourceExport exportResource = new ResourceExport(ds);
            exportResource.setData(resourceData);
            exportResource.exportData(model, true);
        }
        
        StringWriter writer = new StringWriter();
        model.write(writer, General.RDF_LANGUAGE);
        
        return writer.toString();
    }
    

}
